package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import longcaisuyun.longcai.com.yiliubabalongcaisuyun.MyApplication;

/**
 * Created by Administrator on 2016/4/5.
 */
@HttpInlet(Net.LOGIN)
public class PostLogin extends WHAsyPost<PostLogin.Info> {

    public String mobile, password;


    public PostLogin(String name, String pass, AsyCallBack listener) {
        super(listener);
        this.mobile = name;
        this.password = pass;
    }

    @Override
    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.f = object.getString("message");
            if (info.f.equals("1")) {
                info.h = object.getString("driverid");
                info.carid = object.getString("carid");
                info.cityid = object.getString("cityid");
                info.juli = object.getString("juli");
                MyApplication.myPreferences.saveUid(object.getString("driverid"));
                MyApplication.myPreferences.saveCarId(info.carid);
                MyApplication.myPreferences.saveCityid(info.cityid);
                MyApplication.myPreferences.savejuli(info.juli);
            }
            return info;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }


    public static class Info {
        public String h;
        public String f;
        public String carid;
        public String cityid;
        public String juli;
    }


}